POV-Ray : Newsgroups : povray.programming : >1600 radiosity samples: right costheta distribution? : >1600 radiosity samples: right costheta distribution? Server Time
4 Oct 2024 23:13:21 EDT (-0400)
  >1600 radiosity samples: right costheta distribution?  
From: Apache
Date: 4 Jan 2003 04:44:33
Message: <3e16ad01$1@news.povray.org>
I'm working on some C code that generates radiosity sample data. I want to
have more than 1600 samples available. I have posted an image at pbi that
I'm referring to in this post.

Firstly, this piece of code creates a random distribution on a sphere
(without bunches near the pole):

/*---------code snippet----------*/
#define RANDOMVALUE     ((float)rand()/(float)(RAND_MAX))
  for (i = 0; i < SAMPLESAMOUNT; i1++) {
    float costheta = RANDOMVALUE*2-1;     // -1 <= costheta <= 1
    float phi = 2 * PI * RANDOMVALUE;     // 0 <= phi <= 2*pi
    float squareroot = sqrt(1-costheta*costheta);

    x[i1] = cos(phi) * squareroot;
    y[i1] = sin(phi) * squareroot;
    z[i1] = costheta;
  }
/*----------end of code snippet-------*/

Secondly I have some code that moves the samples a bit around in order to
divide the samples more evenly. This way there won't be local gaps or
bunches in the distribution. The resulting distribution is visible in the
upper row (part A and B at pbi).

After that I have moved the samples again with this piece of code:

/*----------code snippet---------*/
  for (i = 0; i < SAMPLESAMOUNT; i++) {
    float phi   = .5 * PI;
    float theta   = .5 * PI;
    float q       = sqrt(x[i]*x[i]+y[i]*y[i]);

    if (x[i1] != 0) { phi = atan(y[i1]/x[i]); }
    if (x[i1] < 0) { phi = PI + alpha; }
    if (q != 0) { theta = atan(z[i]/q); }

    theta = PI*.5*sqrt(theta/(PI*.5));  //this line actually moves the
samples

    x[i] = cos(phi)*cos(theta);
    y[i] = sin(phi)*cos(theta);
    z[i] = sin(theta);
  }
/*----------end of code snippet--------*/

Finally I order the samples and write them to disk (see C and D in the image
at pbi). By ordering them, the set also is distributed the right way when
only the first few samples are being used. (Think of count 35 etc etc etc.)


Additional graphs:
E: statistical data derived from the 1600 samples from POV-Ray 3.5
F: the properties of the data generated by my code.


And now my question:
IS MY DISTRIBUTION CORRECT?
I'm wondering this because the pink line (x*x+z*z) in part E of the picture
isn't completely straight. Especially the second half at the upper right
(sample 1000 and higher) is bent.



Regards,
Apache


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.